<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>会员列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
		<meta name="renderer" content="webkit" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<link rel="stylesheet" href="/holiday/static/css/font.css" />
		<link rel="stylesheet" href="/holiday/static/css/weadmin.css" />
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
		  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
		  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
		
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
				<a href="javascript:;">首页</a>
				<a href="javascript:;"> <cite>节假日管理</cite></a>
			</span>
			<a class="layui-btn layui-btn-sm" style="margin-top:3px;float:right" href="javascript:location.replace(location.href);"
			 title="刷新">
				<i class="layui-icon layui-icon-refresh"></i>
				<!-- <i class="layui-icon" style="line-height:30px">&#x1002;</i> -->
			</a>
		</div>

		<div class="weadmin-body">
			<div class="layui-row">
				<form class="layui-form layui-col-md12 we-search">
					节假日搜索（编辑中）：
					<div class="layui-inline">
						<input class="layui-input" placeholder="开始日" name="start" id="start" />
					</div>
					<div class="layui-inline">
						<input class="layui-input" placeholder="截止日" name="end" id="end" />
					</div>
					<div class="layui-inline">
						<input type="text" name="username" placeholder="请输入搜索关键字" autocomplete="off" class="layui-input" />
					</div>
					<button class="layui-btn" lay-submit="" lay-filter="sreach">
						<i class="layui-icon layui-icon-search"></i>
					</button>
				</form>
			</div>
			<div class="weadmin-block">
				<button class="layui-btn layui-btn-danger" onclick="delAll()">
					<i class="layui-icon layui-icon-delete"></i>批量删除
				</button>
				<button class="layui-btn" onclick="WeAdminShow('添加节假日','/holiday/static/pages/holiday/add.html',700,500)">
					<i class="layui-icon layui-icon-add-circle-fine"></i>添加
				</button>
				<span id="count" class="fr" style="line-height:40px">共有数据：88 条</span>
			</div>
			<table class="layui-table" id="memberList">
				<thead>
					<tr>
						<th>
							<div class="layui-unselect header layui-form-checkbox" lay-skin="primary">
								<i class="layui-icon">&#xe605;</i>
							</div>
						</th>
						<th>ID</th>
						<th>日期</th>
						<th>星期</th>
						<th>是否应该放假</th>
						<th>节假日名字</th>
						<th>当日类型</th>
						<th>更新时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<!-- <tr data-id="2">
						<td>
							<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="2">
								<i class="layui-icon">&#xe605;</i>
							</div>
						</td>
						<td>2</td>
						<td>小明</td>
						<td>女</td>
						<td>13000000000</td>
						<td>admin@mail.com</td>
						<td>北京市 海淀区</td>
						<td>2017-01-01 11:11:42</td>
						<td class="td-status">
							<span class="layui-btn layui-btn-normal layui-btn-xs">已启用</span>
						</td>
						<td class="td-manage">
							<a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">
								<i class="layui-icon layui-icon-download-circle"></i>
							</a>
							<a title="编辑" onclick="WeAdminEdit('编辑','./edit.html', 2, 600, 400)" href="javascript:;">
								<i class="layui-icon layui-icon-edit"></i>
							</a>
							<a onclick="WeAdminShow('修改密码','./password.html',600,400)" title="修改密码" href="javascript:;">
								<i class="layui-icon layui-icon-util"></i>
							</a>
							<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
								<i class="layui-icon layui-icon-delete"></i>
							</a>
						</td>
					</tr> -->
				</tbody>
			</table>
			<div class="page">
				<div>
					<a class="prev" href="" id="prev">&lt;&lt;</a> 
					<!-- <a class="num" href="" >1</a> -->
					<span class="current" id="current">2</span> 
					<!-- <a class="num" href="" >3</a> -->
					<!-- <a class="num" href="">489</a>  -->
					<a class="next" href="" id="next">&gt;&gt;</a>
				</div>
			</div>
		</div>
		<!--<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>-->
		<script src="/holiday/static/lib/layui/layui.js" charset="utf-8"></script>
		<script src="/holiday/static/js/eleDel.js" type="text/javascript" charset="utf-8"></script>
		<script>
			function getQueryString(name) {
				var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if(r!=null)return  unescape(r[2]); return null;
			}
			layui.use(['laydate', 'jquery', 'admin'], function() {
				var laydate = layui.laydate,
					$ = layui.jquery,
					admin = layui.admin;
					//初始化数据
					$(function() {
						var page = parseInt(getQueryString("page") != null ? getQueryString("page"):1);
						var size = parseInt(getQueryString("size") != null ? getQueryString("size"):10);
						
						$.get("/holiday/holiDate/totalSize", function(res) {
							var count = res.data
							var nextPage;
							var prevPage;
							$("#count").html("共有数据：" + count + " 条")
							$("#current").html(page)

							var totalPage = parseInt(((count + size - 1) / size));
							prevPage = (page == 1 ? 1 : page - 1)
							console.log(totalPage)
							console.log(page)
							console.log(page == totalPage)
							nextPage = (page == totalPage ? totalPage : page + 1)
							$("#prev").attr("href", "/holiday/pages/holiday/holiday.html?page="+prevPage+"&size="+size)
							$("#next").attr("href", "/holiday/pages/holiday/holiday.html?page="+nextPage+"&size="+size)
						})
						$.get("/holiday/holiDate/pageAndSize?page="+page+"&size="+size, function(res) {
							res.data.forEach(item => {
								var _len = $('#memberList tr').length;
								var holidayType;
								switch(item.holidayType) {
									case 0:
										holidayType = "正常上班";
										break;
									case 1:
										holidayType = "周末";
										break;
									case 2:
										holidayType = "节假日";
										break;
									case 3:
										holidayType = "调休上班";
										break;
								}
								var weekStr = "星期";
								switch(item.weekday) {
									case 0:
										weekStr = weekStr + "天";
										break;
									case 1:
										weekStr = weekStr + "一";
										break;
									case 2:
										weekStr = weekStr + "二";
										break;
									case 3:
										weekStr = weekStr + "三";
										break;
									case 4:
										weekStr = weekStr + "四";
										break;
									case 5:
										weekStr = weekStr + "五";
										break;
									case 6:
										weekStr = weekStr + "六";
										break;
								}
								$('#memberList tbody').append(						
									'<tr data-id="' + item.ID + '">' +
										'<td>'+
											'<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="' + item.ID + '"><i class="layui-icon">&#xe605;</i></div>'+
										'</td>'+
										'<td>' + item.ID + '</td>'+
										'<td>'+item.dateTime.substring(0,10)+'</td>'+
										'<td>'+ weekStr +'</td>'+
										'<td>'+ (item.holiday == 1 ? "放假" : "上班")+'</td>'+
										'<td>'+item.holidayName+'</td>'+
										'<td>'+holidayType+'</td>'+
										'<td>'+item.UpdatedAt.substring(0,19).replace("T", " ")+'</td>'+
										'<td class="td-status"><span class="layui-btn layui-btn-normal layui-btn-xs">已启用</span></td>'+
										'<td class="td-manage">'+
											// '<a onclick="member_stop(this,\'10001\')" href="javascript:;" title="启用"><i class="layui-icon">&#xe601;</i></a>'+
											'<a title="编辑" onclick="WeAdminShow(\'编辑\',\'/holiday/static/pages/holiday/edit.html?id='+ item.ID +' \',700,500)" href="javascript:;"><i class="layui-icon">&#xe642;</i></a>'+
											// '<a onclick="WeAdminShow(\'修改密码\',\'./password.html\',600,400)" title="修改密码" href="javascript:;"><i class="layui-icon">&#xe631;</i></a>'+
											'<a title="删除" onclick="holidayDel(' + item.ID +')" href="javascript:;"><i class="layui-icon">&#xe640;</i></a>'+
										'</td>'+
									'</tr>'	
								);
							});
						})
					})
			})
		</script>
	</body>
</html>
